.TH std::wcslen 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::wcslen \- std::wcslen

.SH Synopsis
   Defined in header <cwchar>
   std::size_t wcslen( const wchar_t* str );

   Returns the length of a wide string, that is the number of non-null wide characters
   that precede the terminating null wide character.

   The behavior is undefined if there is no null character in the wide character array
   pointed to by str.

.SH Parameters

   str - pointer to the null-terminated wide string to be examined

.SH Return value

   The length of the null-terminated wide string str.

.SH Possible implementation

   std::size_t wcslen(const wchar_t* start)
   {
       // NB: start is not checked for nullptr!
       const wchar_t* end = start;
       while (*end != L'\\0')
           ++end;
       return end - start;
   }

.SH Example


// Run this code

 #include <clocale>
 #include <cwchar>
 #include <iostream>

 int main()
 {
     const wchar_t* str = L"爆ぜろリアル！弾けろシナプス！パニッシュメントディス、ワールド！";

     std::setlocale(LC_ALL, "en_US.utf8");
     std::wcout.imbue(std::locale("en_US.utf8"));
     std::wcout << "The length of \\"" << str << "\\" is " << std::wcslen(str) << '\\n';
 }

.SH Output:

 The length of "爆ぜろリアル！弾けろシナプス！パニッシュメントディス、ワールド！" is 32

.SH See also

   strlen returns the length of a given string
          \fI(function)\fP
   mblen  returns the number of bytes in the next multibyte character
          \fI(function)\fP
   C documentation for
   wcslen
